﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DLL;
using PagedList;

namespace BLL
{
    public class InProductService
    {
        public InProductRepo m_InProductRepo;

        public InProductService()
        {
            m_InProductRepo = new InProductRepo();
        }

        public InProductService(string connectionString)
        {
            m_InProductRepo = new InProductRepo(connectionString);
        }

        #region Paper
        public List<pInProdPaper_Get_Result> GetInProdPaper(DateTime? fromDate = null, DateTime? toDate = null)
        {
            return m_InProductRepo.GetInProdPaper(fromDate, toDate);
        }

        public void UpdateInProdPaper(InProdPaper paper)
        {
            m_InProductRepo.UpdateInPaper(paper);
        }

        public void DeleteInProdPaper(int id)
        {
            m_InProductRepo.DeleteInProdPaper(id);
        }

        public void AddInPaper(InProdPaper paper)
        {
            m_InProductRepo.AddInPaper(paper);
        }
        #endregion Paper

        #region Detail
        public List<pInProdDetail_Get_Result> GetInProdDetails(int paperId)
        {
            return m_InProductRepo.GetInProdDetails(paperId);
        }

        public pInProdDetail_Add_Result AddInProdDetail(int amount, int productId, int price, int inProdPaperId = 0, int createBy = 0, DateTime? date = null )
        {
            return m_InProductRepo.AddInProdDetail(amount, productId, price, inProdPaperId, createBy, date);
        }

        public int UpdateInProdDetail(int id, int? amount = null, int? inputPrice = null)
        {
            return m_InProductRepo.UpdateInProdDetail(id, amount, inputPrice);
        }

        public int DeleteInProdDetail(int id)
        {
            return m_InProductRepo.DeleteInProdDetail(id);
        }

        public List<pInProdHistory_Get_Result> GetInProductHistory(int productId, DateTime? fromDate = null, DateTime? toDate = null)
        {
            return m_InProductRepo.GetInProductHistory(productId, fromDate, toDate);
        }       
        #endregion Detail        
    }
}
